package com.shtel.paas.monitorcenter.util;

import java.util.Collection;
import java.util.List;

import com.github.pagehelper.PageInfo;

public class Page<T> {

	private Collection<T> data;

	public static <T> Page<T> build(List<T> rows) {
		Page<T> page = new Page<T>();
		PageInfo<T> pageInfo = new PageInfo<T>(rows);
		page.setData(pageInfo.getList());
		page.setPageSize(pageInfo.getPageSize());
		page.setTotalElements(pageInfo.getTotal());
		page.setTotalPages(pageInfo.getPages());
		page.setPageNumber(pageInfo.getPageNum());
		return page;
	}
	/**
	 * @return the pageSize
	 */
	public int getPageSize() {
		return pageSize;
	}

	/**
	 * @return the totalElements
	 */
	public long getTotalElements() {
		return totalElements;
	}

	/**
	 * @return the totalPages
	 */
	public long getTotalPages() {
		return totalPages;
	}

	/**
	 * @return the pageNumber
	 */
	public int getPageNumber() {
		return pageNumber;
	}

	/**
	 * @return the data
	 */
	public Collection<T> getData() {
		return data;
	}

	/**
	 * @param pageSize the pageSize to set
	 */
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}

	/**
	 * @param totalElements the totalElements to set
	 */
	public void setTotalElements(long totalElements) {
		this.totalElements = totalElements;
	}

	/**
	 * @param totalPages the totalPages to set
	 */
	public void setTotalPages(long totalPages) {
		this.totalPages = totalPages;
	}

	/**
	 * @param pageNumber the pageNumber to set
	 */
	public void setPageNumber(int pageNumber) {
		this.pageNumber = pageNumber;
	}

	/**
	 * @param data the data to set
	 */
	public void setData(Collection<T> data) {
		this.data = data;
	}

	private int pageSize;
	private long totalElements;
	private long totalPages;
	private int pageNumber;
}
